<!DOCTYPE html>
<html lang="zh-Hans">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"sophimp.gitee.io","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="在BambooIV 的帮助下， Nubia Z18 mini 终究是点亮了，复盘总结一波。">
<meta property="og:type" content="article">
<meta property="og:title" content="Nubia z18 mini 移植总结">
<meta property="og:url" content="http://sophimp.gitee.io/2019/11/12/android/rom/nx611j_port_review/index.html">
<meta property="og:site_name" content="Sophimp&#39;s Space">
<meta property="og:description" content="在BambooIV 的帮助下， Nubia Z18 mini 终究是点亮了，复盘总结一波。">
<meta property="article:published_time" content="2019-11-12T08:22:59.000Z">
<meta property="article:modified_time" content="2021-03-15T03:49:47.930Z">
<meta property="article:author" content="Sophimp">
<meta property="article:tag" content="ROM">
<meta property="article:tag" content="mokee">
<meta property="article:tag" content="Nubia Z18 mini">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://sophimp.gitee.io/2019/11/12/android/rom/nx611j_port_review/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-Hans'
  };
</script>

  <title>Nubia z18 mini 移植总结 | Sophimp's Space</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

	
	<script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
	

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Sophimp's Space</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">coding & thinking</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

  <a href="https://github.com/sophimp" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
    <link itemprop="mainEntityOfPage" href="http://sophimp.gitee.io/2019/11/12/android/rom/nx611j_port_review/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="Sophimp">
      <meta itemprop="description" content="A dream begin">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sophimp's Space">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Nubia z18 mini 移植总结
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2019-11-12 16:22:59" itemprop="dateCreated datePublished" datetime="2019-11-12T16:22:59+08:00">2019-11-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2021-03-15 11:49:47" itemprop="dateModified" datetime="2021-03-15T11:49:47+08:00">2021-03-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android/" itemprop="url" rel="index"><span itemprop="name">Android</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="Views" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">Views: </span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
            <div class="post-description">在BambooIV 的帮助下， Nubia Z18 mini 终究是点亮了，复盘总结一波。</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>进展: </p>
<pre><code>z18 mini 的mokee 移植任务于2019年9月30号交付, 截止10月中旬测试, 主要修复了诱发过程不上数的问题, 长短信诱发问题. windows下usb识别的问题, 目前系统满足诱发功能使用, 可视为趋于稳定,  该系统目前仍存在问题, 摄像机录像功能暂不可使用(拍照功能正常). 

由于前几周, 数传终端和主被结合项目的维护工作优先级更高, 期间断断续续整理了此次移植过程中的笔记, 资料, 至本月附上总结一并分享. </code></pre><p>结果: </p>
<pre><code>本次rom移植已带来的可见好处: 
1. 短信诱发效率更快, 可护展性更高, 更新PDU已解耦在上层可控, 若PDU方案有更新需求, 可以做到只升级pda即可, 而不必去升级rom. 
2. 源码可控, 可以应对更复杂的需求, pdu方案更新解耦应用是如此, 电话拨打诱发挂断的问题解决也是如此, 挂断功能甚至可以做到安全挂断, 而不用去多次试验校准挂断时间. 同时可控性强也不用局限于xposed方案的更新速度. 
3. 可兼容性, 同一个rom 也可以与xposed兼容, 当作xposed方案的备选rom. 
4. 可以与公司产品融合度更高, 无论是技术保障, 品牌文化, 还是产品体验上都有更多的可能待发现. 

存在的蔽端:
1. 工程复杂, 涉及到的知识多, 学习周期长, 导致移植周期较长, 这个问题可随着技术的积累, 逐渐有所改善</code></pre><p>感想:</p>
<pre><code>本次z18 mini 的移植, 极大地增强了对 rom移植 方案的信心, 后续的rom 移植, 虽说工期长, 但是随着技术的积累, 风险相对来说降低了. 

在android 9.0 后续的版本上, 谷歌对 aosp 系统升级方案 有了较大的调整, ROM 的移植工作可以减少对于vendor方的驱动库适配, 因为treble project 技术将厂商的升级与系统的升级解耦了.  后续的移植工作主要精力放在kernel 适配, 驱动配置编译, device 资源覆盖, 启动脚本配置上, 同时也可以减少shim层的适配的工作. 

本次移植的整个rom 适配的流程: 找到合适的内核编译 -&gt; 验证编译出的内核可用性 -&gt; 编写 device 编译信息与资源覆盖脚本 -&gt; 编写vendor下的资源覆盖脚本 -&gt; 编译工程 -&gt; 刷机验证rom -&gt; 测试每个功能, 修复问题. 

涉及到的关键技术点: kernel 的编译, kernel项目的构成, 针对手机硬件, 驱动配置与启动脚本的编写, 整个mokee/aosp项目的结构, 各模块功能, 编译系统及脚本语言, 通过编译命令入手, 搞懂适配的工作流程, selinux, avb 校验, 刷机原理, android 引导及启动流程, kernel 打补丁, vndk 框架, trebl project 技术, 等等, 大部分技术点知道怎么回事即可, 方便于编译脚本的调试, 遇到问题, 找到解决方向. 

此次移植过程, 在recovery上也吃过不少亏, 像z18mini 官方rom v224 以后的版本, 通过第三方的recvoery 就不能直接刷机, 必须通过官方的recvoery刷机, 但是官方的recovery除了升级自身的rom, 没有其他作用, 这增加了刷机的流程, 因此也尝试去简单适配了下twrp 的recvoery移植, 有了rom 适配的经验, revoery工程的跑通就容易的多, 目前已经twrp的工程正常可用, 但是功能较少, 缺少root功能, 缺少汉化, 缺少其他高级功能. 后续可以按需再移植recovery而不必局限于第三方rom. 

bootloader 与 fastboot, 刷机的基本工具也很重要, bootloader 是引导程序, 由手机soc刷入, 角色类似于uboot, grub, mbr, 目前还没有找到合适的途径去刷bootloader, fastboot是aosp工程中自带的与bootloader通信的工具, 本次刷机中, 也遇到fastboot 不可用的情况: 在ubuntu 16.04 lts 系统上 fastboot对于小米8, 小米6x, 努比亚z18 mini不可用. 而用第三方recvoery制作者提供的fastboot 就可以用, 此问题也暂未解决, 目前每次刷机还是将编译好的recovery.img移到windows上刷机, 影响了rom验证的效率. 初步定位应该是手机厂商对 bootloader 做了修改, 应该需要对fastboot做出相应的调整, 后续研究fastboot源码, 以期解决.  

内核知识的学习, android 的内核是基于linux的内核做了一些修改, 而ROM移植工作出现在的问题主要集中在三个部分: 基于适配机型的整个工程的编译, 编译出的ROM刷机点亮, 点亮后的系统正常工作. 后两部分遇到问题的突破点大都是与内核相关, 因此整体学习一下linux内核的工程架构, 也是很有必要. 本次的解决办法就比较投机, 是基于同型号的已移植的内核, 通过工具对比打出差异补丁, 反复编译内核, 试验解决问题的, 这种做法虽然投机, 但是很被动, 若是没有参考的同型号已移植内核源码, 就无从下手, 最根本的解决办法还是攻克内核的配置与编译. 

没有学不会的技术, 是本次ROM移植过程中比较深的感触, 个人的精力是有限的, 这是客观事实, 但是不能因此成为畏惧未知的理由. 有些知识, 没有精力去深研, 但是得了解个大概是非常有必要的, 见得多了至少会在遇到问题的时候提供更广的方向, 思路去解决问题, 同样也可以为团队协作减少技术的沟通成本. 技术学到最后, 孤立的知识点都会以某种形式连成面, 这种形式或是视觉形式的产品, 或是思维形式的流派, 或是项目工程的架构. </code></pre><p>后续计划:</p>
<pre><code>继续维护后续系统可能出现的问题, 关注下一款机型的选型, 待命ROM移植, 将整个 rom 的移植流程逐渐规范化, 建设rom 相关的技术积累. </code></pre>
    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/ROM/" rel="tag"># ROM</a>
              <a href="/tags/mokee/" rel="tag"># mokee</a>
              <a href="/tags/Nubia-Z18-mini/" rel="tag"># Nubia Z18 mini</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2019/10/30/android/tools/busybox_install/" rel="prev" title="Busybox 安装">
      <i class="fa fa-chevron-left"></i> Busybox 安装
    </a></div>
      <div class="post-nav-item">
    <a href="/2019/11/28/android/personal_library_accumulate/" rel="next" title="个人开发的积累">
      个人开发的积累 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Sophimp"
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">Sophimp</p>
  <div class="site-description" itemprop="description">A dream begin</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">86</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">categories</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">89</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/sophimp" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sophimp" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:sophimp2020@126.com" title="E-Mail → mailto:sophimp2020@126.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Sophimp</span>
</div>

<!--
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a>
  </div>
-->

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="Total Visitors">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="Total Views">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
